﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SPWebShell
{
    public class Util
    {
        /// <summary>
        /// Decodes the specified URL.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public string DecodeUrl(string url)
        {
            return System.Web.HttpUtility.UrlDecode(url);
        }
        /// <summary>
        /// Input: http://server/sites/siteA/doclib/cool.xls 
        /// Output:http://server/sites/
        /// </summary>
        /// <param name="fullUrl"></param>
        /// <returns></returns>
        public string GetServerWithSchemeAndPort(string fullUrl)
        {
            Uri u = new Uri(fullUrl);
            return string.Format("{0}://{1}:{2}", u.Scheme, u.Host, u.Port);
        }
    }
}
